package com.itheima.controller;

import com.itheima.common.constant.MessageConstant;
import com.itheima.common.entity.Result;
import com.itheima.service.SetmealService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

@Slf4j
@RestController("userSetmealController")
@RequestMapping("/setmeal")
public class SetmealController {

    @Autowired
  private SetmealService setmealService;


    //查询所有套餐
    @PostMapping("/getSetmeal")
    public Result getSetmeal() {
        log.info("查询所有套餐");
        return new Result(true, MessageConstant.QUERY_SETMEAL_SUCCESS,setmealService.findAll() );
    }

    //查询套餐详情
    @PostMapping("/findById")
    public Result findById(@RequestParam Integer id){
        log.info("根据id查询套餐 {}", id);
        return  new Result(true, MessageConstant.QUERY_SETMEAL_SUCCESS,setmealService.findById(id));
    }
}
